Subject: Re: SAS/C 6.0: schelp crashes w/KS1.2
From: [email-masked] (James Cooper)
Date: 22 Oct 92 14:17:45 GMT
Newsgroups: comp.sys.amiga.programmer

In article <[email-masked]>, [email-masked] (Michael Jansson) writes:
>
>In article <[email-masked]>, [email-masked] (Doug Walker) writes:
>
>> |> Changing the __stack variable doesn't seem to do anything to my stack size, according
>> |> to Xoper. I always get the stack size I set in the shell. Is there anything special I
>> |> should do?
>>
>> It's working.  Xoper reports the stack size and limits given in the Task structure for
>> the task; when you specify __stack, you get a new stack allocated, but the Task
>> structure fields are not modified.
>
>Is there a reason for that? I guess I role my own code with SwapStack (or was it
>StackSwap :-) then, since programs with __stack will be slower otherwise. The
>reason for that is that some functions in the OS checks for the size of the stack
>of the caller. If the stack is too small or bogus (as with SAS) then they will
>allocate a new stack, swap it in, and then de-allocate it when finished. This
>takes time, especially the de-allocation. The same thing goes for other resident
>libraries that are written in a sensible way, i.e. check the stack of the caller.

Yes, there's a reason.  StackSwap() doesn't exist prior to 2.0, so we'ld
have to special case it (since there are a lot of 1.3 users still out
there), which would make your code bigger, and people are always yelling
when their programs come out bigger...  :-\

Also, if I remember correctly, the system libraries check the amount of
stack *left*, not the amount total.  This means they should use the
stack already in place in the task structure, since we won't have put
anything at all on it... the only thing that will be there is whatever
the system puts in place at process startup time.

Besides, this doesn't always happen!  We check the amount of stack the
task already has allocated, and if that amount is >= the value in the
__stack variable, we don't allocate a new stack, we just let it use the
current one, just like it always did.

__stack is both a safety feature and a documentation saver.  For safety,
it makes sure your code has a big enough stack, no matter what size the
user has set in his shell, and you no longer have to document a stack
size to set, since the startup code will allocate it for you if the user
didn't set enough beforehand.

-- 
---------------
Jim Cooper
([email-masked])                             bix: jcooper

Any opinions expressed herein are mine (Mine, all mine!  Ha, ha, ha!),
and not necessarily those of my employer.